﻿var Electronicfencewin = null;

function setupElectronicfence() {
    var efstr;
    if (Electronicfencewin != null) {
        Electronicfencewin.close();
    }
    if ((curVID != 0) && (curLicensePlate != "")) {
        Electronicfencewin = new Ext.Window({
            title: curLicensePlate + " - 电子围栏",
            //bbar: [{ icon: "images/into.gif", text: "", handler: Intothetrigger, tooltipType: "title", tooltip: "进入触警" }, { icon: "images/out.gif", text: "", handler: outthetrigger, tooltip: "退出触警", tooltipType: "title" }, { icon: "images/drop-no.gif", text: "", handler: Canceltrigger, tooltip: "取消触警", tooltipType: "title" }, { icon: "images/Drawef.gif", text: "", handler: Drawef, tooltip: "绘制围栏", tooltipType: "title" }, { icon: "images/CancelDrawef.gif", text: "", handler: CancelDrawef, tooltip: "取消绘制", tooltipType: "title"}],
            bbar: [{ icon: "./images/Drawef.gif", text: "", handler: Drawef, tooltip: "绘制围栏", tooltipType: "title" }, { icon: "./images/CancelDrawef.gif", text: "", handler: CancelDrawef, tooltip: "取消绘制", tooltipType: "title"}],
            html: "<IFRAME  border='0' id='Electronicfencemap' name='Electronicfencemap' src='./Services/rectangle.html' frameBorder='0' width='100%' height='100%' scrolling='no'></IFRAME>",
            listeners: { "beforedestroy": function(obj) {
                Electronicfencewin = null;
            }
            },
            maximizable: false,
            maximized: true
        });
        Electronicfencewin.show();
    }
}

function Drawef() {
    document.getElementById("Electronicfencemap").contentWindow.startDraw();
}
function CancelDrawef() {
    document.getElementById("Electronicfencemap").contentWindow.cancelDraw();
}

function stargetef() {
    if (curVID != 0) {
        Ext.Ajax.request({
            url: "./Json/GetData.ashx",
            params: {
                op: "GET_AREA",
                vid: curVID
            },
            success: function(response, options) {
                obj = Ext.decode(response.responseText);
                if (obj.singleInfo != '') {
                    var efarray = new Array();
                    efarray = obj.singleInfo.toString().split(",");
                    var lng1 = efarray[0];
                    var lat1 = efarray[1];
                    var lng2 = efarray[2];
                    var lat2 = efarray[3];
                    var cx = efarray[4];
                    var cy = efarray[5];
                    var zoom = efarray[6];
                    document.getElementById("Electronicfencemap").contentWindow.createArea(lng1, lat1, lng2, lat2, cx, cy, zoom); //这里有可能出错，当dzwlmain.html没执行完就调用这个函数肯定出错
                }
            }
        });
    }
}